package com.ai.enviro.module.system.dao.local;

import com.ai.enviro.module.system.dao.IotEnvStorage;
import com.ai.enviro.module.system.dao.dataobject.IotEnvDO;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public class IotEnvLocalStorage implements IotEnvStorage {
    private int temperature;
    private int humidity;
    @Override
    public void save(int temperature, int humidity) {
        this.temperature = temperature;
        this.humidity = humidity;
    }

    @Override
    public IotEnvDO getIotEnv() {
        IotEnvDO env = new IotEnvDO();
        env.setHumidity(new BigDecimal(humidity).divide(new BigDecimal(10)));
        env.setTemperature(new BigDecimal(temperature).divide(new BigDecimal(10)));
        return env;
    }
}
